Is there a way to simplify isalpha len function in a while loop